API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector : public ByteAlignedClass<16>
12  {
13  public :
14 
15  union
16  {
17  float _x ;
18  float _r ;
19  float x ;
20  float r ;
21  } ;
22 
23  union
24  {
25  float _y ;
26  float _g ;
27  float y ;
28  float g ;
29  } ;
30 
31  union
32  {
33  float _z ;
34  float _g ;
35  float z ;
36  float g ;
37  } ;
38 
39  union
40  {
41  float _w ;
42  float _a ;
43  float w ;
44  float a ;
45  } ;
46 
47  public :
48 
53  Vector () ;
62  Vector (float x, float y) ;
72  Vector (float x, float y, float z) ;
81  Vector (float x, float y, float z, float w) ;
87  Vector (const Vector& other) ;
93  Vector (const IntVector& other) ;
97  ~Vector () ;
98 
102  float getX () const ;
106  float getY () const ;
110  float getZ () const ;
114  float getW () const ;
115 
116  // Setters
122  void setX (float value) ;
128  void setY (float value) ;
134  void setZ (float value) ;
140  void setW (float value) ;
141 
142  // Add
148  void addX (float value) ;
154  void addY (float value) ;
160  void addZ (float value) ;
166  void addW (float value) ;
172  void multX (float value) ;
178  void multY (float value) ;
184  void multZ (float value) ;
190  void multW (float value) ;
191 
192  // Length
196  float getLengthVec2 () const ;
200  float getLengthVec3 () const ;
204  float getLengthVec4 () const ;
210  float getLengthSquaredVec2 () const ;
216  float getLengthSquaredVec3 () const ;
222  float getLengthSquaredVec4 () const ;
223  // Distance
228  float getDistanceVec2 (const Vector& other) const ;
233  float getDistanceVec3 (const Vector& other) const ;
238  float getDistanceVec4 (const Vector& other) const ;
245  float getDistanceSquaredVec2 (const Vector& other) const ;
252  float getDistanceSquaredVec3 (const Vector& other) const ;
259  float getDistanceSquaredVec4 (const Vector& other) const ;
260 
266  void normalizeVec2 () ;
272  void normalizeVec3 () ;
276  void normalizeVec4 () ;
289  // Dot product
296  float dotProductVec2 (const Vector& other) const ;
303  float dotProductVec3 (const Vector& other) const ;
310  float dotProductVec4 (const Vector& other) const ;
311  // Cross product
317  void setAsCrossVec3 (const Vector& other) ;
324  Vector getCrossVec3 (const Vector& other) const ;
325 
326  // Practical
333  void fromString (const nkMemory::StringView& str) ;
334 
335  // Operators
342  Vector& operator= (const Vector& other) ;
349  Vector& operator= (const IntVector& other) ;
356  Vector operator+ (const Vector& other) const ;
362  void operator+= (const Vector& other) ;
369  Vector operator- (const Vector& other) const ;
375  void operator-= (const Vector& other) ;
382  Vector operator* (const Vector& other) const ;
388  void operator*= (const Vector& other) ;
395  Vector operator* (const Quaternion& other) const ;
401  void operator*= (const Quaternion& other) ;
408  Vector operator* (const Matrix& mat) const ;
414  void operator*= (const Matrix& other) ;
421  Vector operator* (float coeff) const ;
427  void operator*= (float coeff) ;
434  Vector operator/ (const Vector& other) const ;
440  void operator/= (const Vector& other) ;
447  Vector operator/ (float coeff) const ;
453  void operator/= (float coeff) ;
460  bool operator== (const Vector& other) const ;
467  bool operator!= (const Vector& other) const ;
474  bool operator< (const Vector& other) const ;
481  bool operator<= (const Vector& other) const ;
488  bool operator> (const Vector& other) const ;
495  bool operator>= (const Vector& other) const ;
496 
497  // Statics
498  // Distance
506  static float distanceVec2 (const Vector& a, const Vector& b) ;
514  static float distanceVec3 (const Vector& a, const Vector& b) ;
522  static float distanceVec4 (const Vector& a, const Vector& b) ;
530  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
538  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
546  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
547  // Dot product
555  static float dotVec2 (const Vector& a, const Vector& b) ;
563  static float dotVec3 (const Vector& a, const Vector& b) ;
571  static float dotVec4 (const Vector& a, const Vector& b) ;
572  // Cross product
580  static Vector crossVec3 (const Vector& a, const Vector& b) ;
581  } ;
582 
583  using FloatVector = Vector ;
584 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getZ
float getZ() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector(float x, float y, float z, float w)
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::Vector::getY
float getY() const
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::operator>
bool operator>(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
void setAsCrossVec3(const Vector &other)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Vector::operator==
bool operator==(const Vector &other) const
nkMaths::Vector::operator<
bool operator<(const Vector &other) const
nkMaths::Vector::operator+=
void operator+=(const Vector &other)
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::operator+
Vector operator+(const Vector &other) const
nkMaths::Vector::getW
float getW() const
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::multY
void multY(float value)
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::setZ
void setZ(float value)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector()
nkMaths::Vector::normalizeVec2
void normalizeVec2()
nkMaths::Vector::setY
void setY(float value)
nkMaths::Vector::addZ
void addZ(float value)
nkMaths::Vector::normalizeVec3
void normalizeVec3()
nkMaths::Vector::multW
void multW(float value)
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::operator*
Vector operator*(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::operator-=
void operator-=(const Vector &other)
nkMaths::Vector::setW
void setW(float value)
nkMaths::Vector::operator<=
bool operator<=(const Vector &other) const
nkMaths::Vector::Vector
Vector(const Vector &other)
nkMaths::Vector::multX
void multX(float value)
nkMaths::Vector::~Vector
~Vector()
nkMaths::Vector::setX
void setX(float value)
nkMaths::Vector::addX
void addX(float value)
nkMaths::Vector::addY
void addY(float value)
nkMaths::Vector::operator/=
void operator/=(const Vector &other)
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Vector::Vector
Vector(const IntVector &other)
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::fromString
void fromString(const nkMemory::StringView &str)
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::operator>=
bool operator>=(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::Vector
Vector(float x, float y)
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::operator-
Vector operator-(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::multZ
void multZ(float value)
nkMaths::Vector::addW
void addW(float value)
nkMaths::Vector::operator!=
bool operator!=(const Vector &other) const
nkMaths::Vector::operator*=
void operator*=(const Vector &other)
nkMaths::Vector::operator/
Vector operator/(const Vector &other) const
nkMaths::Vector::getX
float getX() const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector::operator=
Vector & operator=(const Vector &other)
nkMaths::Vector::Vector
Vector(float x, float y, float z)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
void normalizeVec4()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)